package com.ruoyi.web.controller.electricitypole;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.ElectricityPole;
import com.ruoyi.yanjing.service.IElectricityPoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电杆信息Controller
 * 
 * @author whz
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/yanjing/pole")
public class ElectricityPoleController extends BaseController
{
    @Autowired
    private IElectricityPoleService electricityPoleService;

    /**
     * 查询电杆及线路信息列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:selectAllElectricityPoleAndLineInfoList')")
    @GetMapping("/selectAllElectricityPoleAndLineInfoList")
    public AjaxResult selectAllElectricityPoleAndLineInfoList(ElectricityPole electricityPole)
    {
        return success(electricityPoleService.selectElectricityPoleAndLineInfoList(electricityPole));
    }


    /**
     * 查询电杆信息列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:selectAllPoleList')")
    @GetMapping("/selectAllPoleList")
    public AjaxResult selectAllPoleList(ElectricityPole electricityPole)
    {
        return success(electricityPoleService.selectElectricityPoleList(electricityPole));
    }


    /**
     * 查询电杆信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElectricityPole electricityPole)
    {
        startPage();
        List<ElectricityPole> list = electricityPoleService.selectElectricityPoleList(electricityPole);
        return getDataTable(list);
    }

    /**
     * 查询电杆及线路信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:selectElectricityPoleAndLineInfoList')")
    @GetMapping("/selectElectricityPoleAndLineInfoList")
    public TableDataInfo selectElectricityPoleAndLineInfoList(ElectricityPole electricityPole)
    {
        startPage();
        List<ElectricityPole> list = electricityPoleService.selectElectricityPoleAndLineInfoList(electricityPole);
        return getDataTable(list);
    }

    /**
     * 导出电杆信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:export')")
    @Log(title = "电杆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElectricityPole electricityPole)
    {
        List<ElectricityPole> list = electricityPoleService.selectElectricityPoleList(electricityPole);
        ExcelUtil<ElectricityPole> util = new ExcelUtil<ElectricityPole>(ElectricityPole.class);
        util.exportExcel(response, list, "电杆信息数据");
    }

    /**
     * 获取电杆信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(electricityPoleService.selectElectricityPoleById(id));
    }

    /**
     * 新增电杆信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:add')")
    @Log(title = "电杆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElectricityPole electricityPole)
    {
        return toAjax(electricityPoleService.insertElectricityPole(electricityPole));
    }

    /**
     * 修改电杆信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:edit')")
    @Log(title = "电杆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElectricityPole electricityPole)
    {
        return toAjax(electricityPoleService.updateElectricityPole(electricityPole));
    }

    /**
     * 删除电杆信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:pole:remove')")
    @Log(title = "电杆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(electricityPoleService.deleteElectricityPoleByIds(ids));
    }
}
